package com.synnex.mobile.servier.web.msgBoard.controller;

import com.synnex.mobile.generic.core.pager.DataResults;
import com.synnex.mobile.generic.core.pager.Pagination;
import com.synnex.mobile.servier.core.msgBoard.bo.MsgBo;
import com.synnex.mobile.servier.core.msgBoard.bo.criteria.MsgBoardCriteria;
import com.synnex.mobile.servier.core.msgBoard.service.MsgBoardService;
import com.synnex.mobile.servier.web.common.controller.AbstractController;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;

/**
 * @author lancec
 */
public abstract class AbstractMsgBoardController extends AbstractController {

    protected MsgBoardService msgBoardService;

    public void setMsgBoardService(MsgBoardService msgBoardService) {
        this.msgBoardService = msgBoardService;
    }

    protected Map<String, Object> MsgList(HttpServletRequest request) {

        MsgBoardCriteria searchCriteria = new MsgBoardCriteria();
        Pagination pagination = createPagination(request);
        searchCriteria.setPagination(pagination);

        DataResults<MsgBo> results = msgBoardService.getMsgList(searchCriteria);
//        String ftpPath = "http://" + this.getConfig().getFtpHost() + this.getConfig().getFtpDownPath();

        Map<String, Object> model = new HashMap<String, Object>();
        model.put("totalCount", results.getTotalCount());
        model.put("pageNo", pagination.getPageNo());
        model.put("pageSize", pagination.getPageSize());
        model.put("results", results.getResults());
//        model.put("dataWrap", results);
        return model;
    }
}
